<?php

/**
 * Формы новостей
 */
class NewsForm extends Zend_Form {

    /**
     * Форма правки новости
     *
     * @param int $sid #ID секции
     * @param int $nid #ID новости
     * @return NewsForm
     */
    public function News($sid = 0, $nid = 0) {
        $this->setName('news');
        $t = Zend_Registry::get('Zend_Locale');
        $title = new Zend_Form_Element_Text('title');
        $title->setLabel('Title')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty')
                ->setRequired();

        $keywords = new Zend_Form_Element_Textarea('keywords');
        $keywords->setLabel('Keywords')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');

        $description = new Zend_Form_Element_Textarea('description');
        $description->setLabel('Description')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');

        $date = new Zend_Form_Element_Text('date');
        $date->setLabel('Date')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->setAttrib('class', 'datepicker')
                ->addValidator('NotEmpty')
                ->setRequired();

        $preview = new Zend_Form_Element_Text('preview');
        $preview->setLabel('Preview image')
                ->addFilter('StripTags')
                ->setAttrib('class', 'file_fm')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');

        $short = new Zend_Form_Element_Textarea('short');
        $short->setLabel('Brief')
                ->setAttrib('class', 'tinymce')
                ->addValidator('NotEmpty');

        $long = new Zend_Form_Element_Textarea('long');
        $long->setLabel('News')
                ->setAttrib('class', 'tinymce')
                ->addValidator('NotEmpty');

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Save');
        $submit->setAttrib('id', 'submitbutton');

        $this->addElements(array($title,$keywords,$description,$date, $preview, $short, $long, $submit));

        $this->addDisplayGroup(array('title', 'date', 'preview', 'short', 'long'), 'news', array('legend' => $t->_('News')));
        $this->addDisplayGroup(array('description', 'keywords', 'submit'), 'seo', array('legend' => 'SEO'));
        $this->setDisplayGroupDecorators(array(
            'FormElements',
            'Fieldset'
        ));
        $this->setAction(ADMIN_URL . '/pages/modify/id/' . $sid . '/nid/' . $nid . '/a/edit');
        $this->setDefaultTranslator($t);
        return $this;
    }

}